import { Component } from '@angular/core';

import { NavController } from 'ionic-angular';
import { ContactPage } from '../contact/contact'
import { HomePage } from '../home/home'

@Component({
  selector: 'app-list',
  templateUrl: 'appList.html'
})

export class appList {

  public items: Array<{name: string, flag: any}>;
  public itemSelected: any;
  // public concat : ContactPage;

  constructor( public navCtrl: NavController ) {

  }

  ngOnInit() {
    console.log("appList init");
    this.items = [
      {
        name: "测试应用1",
        flag: ContactPage,
        icon: "superpowers"
      },
      {
        name: "测试应用2",
        flag: HomePage,
        icon: "table"
      }
    ];

    this.itemSelected = appList.itemSelected.bind(this);
    console.log(this);
    // this.itemSelected = this.constructor.itemSelected;
  }

  static itemSelected(item : {name: string, flag: string}){
    var that = this;
    console.log("in app" + item.name);
    console.log(that);
    that["navCtrl"].push(item.flag);
  }

}
